var consultRight ;
var consultProductId ;





//--------------------start:投票相关---------------------

//咨询投票
function consultVote(event){
	doRequiredLoginAction(function(){
		$j.post(__ctxPath+'/consult/item/blank.html?doAction=consultVote',{"consultId":event.data.consultId,"chosen":event.data.chosen},consultVoteCallback,"json");
	});
}
//咨询投票callback
function consultVoteCallback(data){
	if (data.result == 1){
		$("span_satisfiedCount_"+data.consultId).innerHTML = data.satisfiedCount;
		$("span_unsatisfiedCount_"+data.consultId).innerHTML = data.unsatisfiedCount;
		alert(__FMT.consult_voteSuccess);
	}else if (data.result == 2){ //已投票
		alert(__FMT.consult_isVoted);
	}
}

//--------------------end: 投票相关---------------------


//--------------------start:发表咨询相关---------------------
//验证检查
function consultFormCheck(){
	var flag = true;
	if($('customerName')!=null){
		applyValidate($('customerName'),"maxlength=20,required,noHtml");
	}
	applyValidate($('message'),"minlength=10,maxlength=500,required,noHtml");
	if(!validateForm($('addConsultForm'))){
		flag = false;
	}
	return flag;
}

//权限检查 0=匿名可评论 1=登录用户
function consultRightCheck(){
	if(consultRight=='0'){
		return;
	}else if(consultRight=='1'){
		doRequiredLoginAction(function(){
			return true;
		});
	}
}

//发表咨询检查 0=匿名可评论 1=登录用户 
function addConsult(){
	if(consultRight=='0'){
		submitConsult();
	}else if(consultRight=='1'){
		doRequiredLoginAction(submitConsult);
	}
}
//提交咨询
var submitFlag = false;
function submitConsult(){
	if(consultFormCheck() && !submitFlag){
		submitFlag = true;
		$('addConsultForm').submit();
	}
} 

//--------------------end:  发表咨询相关---------------------




